<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>更新处方</title>
<jsp:include page="header.jsp"></jsp:include>
<style type="text/css">
	.my-div {
		clear: both;
		height: 42px;
		width: 100%;
		margin-top: 50px;
	}
	.my-up-pic {
			position:relative;
			float:left;
			width: 80px;
			height: 80px;
			margin-left: 10px;
			margin-top:3px;
			font-size:.7rem;
		}
		.my-up-pic img {
			display: block;
			width: 100%;
			height: 100%;
		}
		
		.my-up-pic .btn {
			display: block;
			width: 100%;
			height: 100%;
		}
	.my-up-pic input {
			position: absolute;
			top:0;
			left:0;
			width:100%;
			height:100%;
			opacity: 0;
    		filter: alpha(opacity=0);
    		cursor: pointer;
		}
		#my_content {
			float: left;
			width: 80px;
			height: 80px;
			margin-top:3px;
		}
		#my_content img {
			display: block;
			width: 100%;
			height: 100%;
		}
		.my-span {
			color: red;
			font-size: .7rem;
		}
		.my-add {
			display: block;
			border: none;
			width: 100%;
			height: 42px;
			line-height: 42px;
			font-size: 21px;
			color: #ffffff;
			text-align:center;
			background-color: red;
		}
		
		.weui-media-box__hd img{
			width: 100%;
			height: 100%;
		}
</style>
</head>
<body>
	<div class="weui-content">
		<div class="my-row"></div>
		<div class="weui-panel weui-panel_access">
          <div class="weui-panel__hd"><span>单号：${order.id}</span><span class="ord-status-txt-ts fr">
          	<c:if test="${order.orderState eq '1'}">
	   			未支付
	   			</c:if>
	   			<c:if test="${order.orderState eq '2'}">
	   			未审核
	   			</c:if>
	   			<c:if test="${order.orderState eq '3'}">
	   			已审核
	   			</c:if>
	   			<c:if test="${order.orderState eq '4'}">
	   				未发货
	   			</c:if>
	   			<c:if test="${order.orderState eq '5'}">
	   				已发货
	   			</c:if>
	   			<c:if test="${order.orderState eq '6'}">
	   				已发货
	   			</c:if>
	   			<c:if test="${order.orderState eq '7'}">
	   				已退款
	   			</c:if>
	   			<c:if test="${order.orderState eq '8'}">
	   				未通过审核
	   			</c:if>
          </span></div>
          <div class="weui-media-box__bd  pd-10">
            <div class="weui-media-box_appmsg ord-pro-list" onclick="myDetail('${app.id}')">
              <div class="weui-media-box__hd"><a href="javascript:;"><img class="weui-media-box__thumb" src="${pageContext.request.contextPath }${order.goodsPic}" alt=""></a></div>
              <div class="weui-media-box__bd">
                <h1 class="weui-media-box__desc"><a href="${pageContext.request.contextPath }/phone/detail?id=${order.goodsId}" class="ord-pro-link">${order.goodsName}</a></h1>
                <!-- <p class="weui-media-box__desc">规格：<span>红色</span>，<span>23</span></p> -->
                <div class="clear mg-t-10">
                  <div class="wy-pro-pri fl">¥<em class="num font-15">${order.orderPrice}</em></div>
                  <div class="pro-amount fr"><span class="font-13">数量×<em class="name">${order.orderSum}</em></span></div>
                </div>
              </div>
            </div>
          </div>
    </div>
    <c:if test="${order.orderState eq '8'}">
     <div class="weui-panel weui-panel_access">
     		<span class="my-span">${order.orderPrepare},请重新上传处方!</span>
     </div>
    <div class="weui-panel weui-panel_access">
    	<div class="my-up-pic">
    		<button class="btn">上传处方</button>
            <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple="">
        </div>
        <div id="my_content"></div>
        <form action="/phone/updateOrder" method="post" id="myForm">
				<input type="hidden" name="id" value="${order.id}"/>
				<input type="hidden" name="chufangPic" />
		</form>
        <div class="my-div">
        	<a href="javascript:;" class="my-add">确定上传</a>
        </div>
        </c:if>
    </div>
<jsp:include page="foot.jsp"></jsp:include>
<script type="text/javascript">
	$('#uploaderInput').change(function(){
		var file = this.files[0];
		if(file==null){
			$.toast("请选择上传文件!","text"); 
	    	return false;
	    }
		var rFilter =/^(image\/bmp|image\/gif|image\/jpeg|image\/png|image\/tiff)$/;
		if(!rFilter.test(file.type)){
			$.toast("文件上传的格式不正确!","text"); 
	    	return false;
		}else{
			var formdata = new FormData();
			formdata.append('file',file);  
			 $('#my_mask').show();
				upload(formdata);
			
		}
	});
	$('.my-add').click(function(){
		$('#myForm').submit();
	});
	function upload(formdata){
		$.ajax({  
		     url : "/phone/upload",  
		     type : "POST",  
		     data : formdata, 
	         cache:false,
	         contentType:false,
	         processData:false,
	         beforeSend:function(){
             	$.showLoading();
             },
		     success : function(data) { 
		          if(""!=data){
		        	  $('input[name="chufangPic"]').val(data);
		        	  $.toast("上传文件成功!","text");
		        	  $('#my_content').html();
		        	  var str ='<img src="'+data+'">';
		        	  $('#my_content').html(str);
		        	  $.hideLoading();
		          }
		     },  
		     error : function(data) { 
		    	 $.hideLoading();
		    	 $.toast("上传图片失败!","text");
		     }  
		});  
	}
</script>
</body>
</html>